class Solution {
   public:
    string longestCommonPrefix(vector<string>& strs) {
        int n = strs.size();
        int maxn = 200;
        for (int i = 0; i < n; i++) {
            if (strs[i].size() < maxn) maxn = strs[i].size();
        }
        string ans = "";
        if (maxn == 0) return ans;
        for (int i = 0; i < maxn; i++) {
            char ch = strs[0][i];
            for (int j = 1; j < n; j++) {
                if (strs[j][i] != ch) return ans;
            }
            ans += ch;
        }
        return ans;
    }
};